<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float:left">
    </div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%;margin-top:50px"
      >
        <el-table-column align="center" prop="id" label="序号" width="70" :fixed="isMobile()?'left':undefined"/>
        <el-table-column align="center" prop="live_name" label="直播名称">
          <!-- <template slot-scope="scope">
            <img :src="scope.row.url" width="100%">
          </template> -->
        </el-table-column>
        <el-table-column align="center" prop="live_picture" label="直播海报" width="150">
          <template slot-scope="scope">
            <img :src="scope.row.live_picture"  width="60px" height="80px">
          </template>
        </el-table-column>
         <el-table-column align="center" prop="live_id" label="直播间ID" width="100" />
        <el-table-column align="center" prop="num" label="关看人数" width="80"/>
       <el-table-column align="center" prop="zan" label="点赞人数" width="80"/>
       <el-table-column align="center" prop="duration" label="直播时长" width="80"/>
         <el-table-column align="center" prop="create_time" label="创建时间"  />
        <el-table-column
          align="center"
          prop="telephone"
          :fixed="isMobile()?undefined:'right'"
          width="240"
          label="操作"
        >
          <template slot-scope="scope">
            <el-button
              type="danger"
              size="small"
              icon="el-icon-delete"
              @click="onDel(scope.row.id)"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from '../../components/control/control'
export default {
  name:'live_playpack_list',
  components: { control },
  data() {
    return {
      config: [
        { type: 'text', placeholder: '请输入直播名', field: 'title', val: '' }
      ],
      value: '',
      searchWhere: {
        title: ''
      },
      tableData: [],
      total: 0,
      current_page: 1,
      per_page: 14
    }
  },
  activated(){
    // if(this.$getUpdate()){
      this.onSearch()
    // }
  },
  created() {
    this.onSearch()
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
    onSearch() {
      const form = {}
      form.page = this.current_page
      form.map = this.searchWhere
      console.log(form)
      this.get('/admin/Live/afterLive', form, 'POST').then(e => {
        this.tableData = e.data
        this.per_page = e.per_page
        this.total = e.total
        this.current_page = e.current_page
        // console.log(this.tableData)
      })
    },
    // 添加
    onAdd() {},
    // 编辑
    onEdit(id) {
      console.log(id)
    },
    // 修改状态
    change_status(id, field, val) {
      this.update(id, val, field, 'Ad').then(e => {
        e ? this.onSearch() : ''
      })
    },
    // 删除
    onDel(id) {
      this.$msg_confirm().then(e => {
        if (e) {
          this.get('/admin/Live/dellog?id=' + id, this.form, 'POST').then(e => {
            this.onSearch()
          })
        }
      })
    }
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
